package cn.edu.suda.catalina.dataupdate.controller;

import cn.edu.suda.catalina.dataupdate.entity.Users;
import cn.edu.suda.catalina.dataupdate.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author admin
 * @date 2017/5/23
 */
@RestController
public class UsersController {
    @Autowired
    private UsersService userService;

    @RequestMapping("/userForm")
    public String info(Users user) {
        return userService.save(user) == null ? "添加失败！" : "添加成功！";
    }

    @RequestMapping("/addRedisUser")
    public void add(String key, Users user) {
        userService.add(key, user);
    }

    @RequestMapping("/getRedisUser")
    public Users get(String key) {
        return userService.getUserByKey(key);
    }
}
